package org.budo.redis.repository.util;

import org.budo.support.jedis.util.JedisUtil;
import org.budo.support.spring.util.SpringUtil;

import redis.clients.jedis.JedisPool;

/**
 * @author lmw
 */
public class RedisLockUtil {
    /**
     * 默认2分钟自动过期
     */
    public static void tryLock(String key, Runnable runnable) {
        JedisPool jedisPool = SpringUtil.getBeanCached(JedisPool.class);
        JedisUtil.tryLock(jedisPool, key, runnable, 2 * 60);
    }
}
